
startinstr "Create silent install file"

wasuser = node[:was][:user]
wasgroup = node[:was][:group]
wasuserpw = node[:was][:userpw]
cuser = node[:chef][:user]
cgroup = node[:chef][:group]

deployment = node[:deployment]

directory "#{node[:om][:installParentDir]}" do
  owner wasuser
  group wasgroup
  action :create
end 

runtdbhost=""
search(:node, "deployment:#{deployment}").each do |anode|
	if anode.role?("om_runtdb2")
		runtdbhost = anode[:fqdn]
	end
end

if runtdbhost == ""
	raise "OMS Runtime DB Host node not available !"
end 

template "/tmp/install.silent" do
  source "install.silent.erb"
  owner wasuser
  group wasgroup
  variables(
			:omdbuser => node[:om][:omdbuser],
      :omdbname => node[:om][:omdbname],
      :omdbuserpasswd => node[:db2][:password],
      :omdbhost =>  runtdbhost,
      :omdbport => node[:om][:omdbport],
      :omdbschemaowner => node[:om][:omdbschemaowner],

      :ominstalldir => node[:om][:installDir],
      :ominstallparentdir => node[:om][:installParentDir],

			:loadfactorysetup => ! node[:om][:maintenance],
			:reinitdb => ! node[:om][:maintenance],
			:nodbverify => node[:om][:maintenance],
			:applyddl => ! node[:om][:maintenance],
			
			:omversion => node[:om][:version]
			)
  action :create
end

stopinstr "Create silent install file"

